package com.zn.kjj;

import com.github.pagehelper.PageHelper;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Properties;
import org.apache.ibatis.plugin.Interceptor;
/**
 * ru
 * @author Administrator
 */
@EnableTransactionManagement
@SpringBootApplication
@MapperScan(basePackages = {"com.zn.kjj.dao"}, sqlSessionFactoryRef = "sqlSessionFactory")
public class KjjApplication {
	@Bean
	PageHelper pageHelper(){
		//分页插件
		PageHelper pageHelper = new PageHelper();
		Properties properties = new Properties();
		properties.setProperty("reasonable", "true");
		properties.setProperty("supportMethodsArguments", "true");
		properties.setProperty("returnPageInfo", "check");
		properties.setProperty("params", "count=countSql");
		pageHelper.setProperties(properties);
		//添加插件
		new SqlSessionFactoryBean().setPlugins(new Interceptor[]{pageHelper});
		return pageHelper;
	}
	public static void main(String[] args) {
		SpringApplication.run(KjjApplication.class, args);
	}
}
